import TCategory from '../../entry/TCategory'
import TData from './TData'
import TStatus from './TStatus'

// 验证静态链接
const validateShortLinkName = (rule, value, callback) => {
  if(/^[0-9,a-zA-Z_\-\&\/]*$/.test(value)){
    callback();
  } else {
    callback(new Error('只能输入英文字符、数字、&、_、-和/。'));
  }
};

let status = new TStatus();

// 页面的数据源
let data = new TData();

let addModal={
  isShow:false,
  title:"新增分类",
  isLoading:false,
  classificationState: null,
  modalImageSelect:{
    isShow:false,
    deviceType : 1
  },
  rules: {
    name: [
      {required: true, message: '分类名称不能为空', trigger: 'blur'}
    ],
    shortLinkName: [
      { message: '固定连接不能为空', trigger: 'blur',required: true},
      {validator: validateShortLinkName, trigger: 'blur',required: true}
    ],
  }
}
// 和网络交互相关的参数
let params = {
  classification:new TCategory(),
  moveCategory:{
    classification:new TCategory(),
    parentList:[],
    selectParentClassificationId:"",
  },
  showroomSelected:{
    showroomTitle:'',
    showroomId:'',
    shortLink:''
  }
};

let sortTitles =  [
  {
    title: '分类名称',
    key: 'name',
    align: 'center',
    width: 220,
  },
  {
    title: '排序',
    key: 'sequence',
    align: 'center',
    width: 220,
  },
];

export  default  {
  tParam: params,
  addModal:addModal,
  status:status,
  tData: data,
  tRole: {},
  sortTitles:sortTitles,
};

